{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "collapsed": true,
        "id": "JCfKPwoa61Fx"
      },
      "outputs": [],
      "source": [
        "from __future__ import print_function\n",
        "import torch\n",
        "import numpy as np\n",
        "import torch.optim\n",
        "import torch.nn as nn\n",
        "import torch.optim as optim\n",
        "import torch.nn.init as init\n",
        "import torch.nn.functional as F\n",
        "from torch.autograd import Variable"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\", category=FutureWarning)\n"
      ],
      "metadata": {
        "id": "dP1q5hkL7Ls4"
      },
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "collapsed": true,
        "id": "I-55AkKp61F2"
      },
      "outputs": [],
      "source": [
        "#torch.nn: - Neural networks can be constructed using the torch.nn package."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "48z4bsw_61F3",
        "outputId": "fd9e291b-749b-452c-8648-512ffe54b4fc"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 5])\n",
            "Output size :  torch.Size([100, 5])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "linear = nn.Linear(in_features=10, out_features=5, bias=True)\n",
        "output_linear = linear(x)\n",
        "print('Output size : ', output_linear.size())\n",
        "\n",
        "bilinear = nn.Bilinear(in1_features=10, in2_features=30, out_features=5, bias=True)\n",
        "output_bilinear = bilinear(x, y)\n",
        "print('Output size : ', output_bilinear.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "hZAXdW7b61F4",
        "outputId": "8b3d56ab-31a0-4254-e287-389f2b531146"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 10])\n",
            "Output size :  torch.Size([100, 30])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "sig = nn.Sigmoid()\n",
        "output_sig = sig(x)\n",
        "output_sigy = sig(y)\n",
        "print('Output size : ', output_sig.size())\n",
        "print('Output size : ', output_sigy.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Em-RXt1u61F5",
        "outputId": "06eb30e4-874d-40ef-9fa1-16e170c217a2"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([-1.5454,  0.3599,  2.2720,  0.7115,  0.5296,  0.6176,  1.8854,  0.4854,\n",
            "        -0.3893,  0.8369])\n",
            "tensor([0.1758, 0.5890, 0.9065, 0.6707, 0.6294, 0.6497, 0.8682, 0.6190, 0.4039,\n",
            "        0.6978])\n"
          ]
        }
      ],
      "source": [
        "print(x[0])\n",
        "print(output_sig[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "zBMtVCYW61F6",
        "outputId": "18a7644c-d91b-4d28-b3db-bc0984bb533a"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 10])\n",
            "Output size :  torch.Size([100, 30])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "func = nn.Tanh()\n",
        "output_x = func(x)\n",
        "output_y = func(y)\n",
        "print('Output size : ', output_x.size())\n",
        "print('Output size : ', output_y.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "RHll2pGj61F7",
        "outputId": "a30d72d5-f97c-45b7-c9f6-cc0feeb98cdf"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([ 1.6056,  0.1092,  0.2044,  1.0537, -0.8658, -0.9111, -1.1586, -1.7745,\n",
            "        -0.8922, -2.3219])\n",
            "tensor([ 0.9225,  0.1087,  0.2016,  0.7832, -0.6992, -0.7217, -0.8206, -0.9441,\n",
            "        -0.7125, -0.9809])\n",
            "tensor([ 0.2153,  1.3900,  0.4259, -0.3347, -1.2087, -0.1930,  0.1645, -1.5867,\n",
            "        -0.1752,  0.3863,  0.6141,  1.6769, -0.8080,  0.3790, -0.7446,  0.1795,\n",
            "        -1.5132,  0.8282,  1.6872,  0.7207, -0.6874,  0.0136,  0.3600,  1.9525,\n",
            "        -0.1363, -0.2002,  0.4026, -0.1413,  2.2343,  1.0469])\n",
            "tensor([ 0.2121,  0.8832,  0.4019, -0.3228, -0.8363, -0.1907,  0.1631, -0.9196,\n",
            "        -0.1735,  0.3682,  0.5470,  0.9325, -0.6685,  0.3619, -0.6319,  0.1776,\n",
            "        -0.9075,  0.6795,  0.9338,  0.6173, -0.5963,  0.0136,  0.3452,  0.9605,\n",
            "        -0.1355, -0.1976,  0.3821, -0.1404,  0.9773,  0.7806])\n"
          ]
        }
      ],
      "source": [
        "print(x[0])\n",
        "print(output_x[0])\n",
        "print(y[0])\n",
        "print(output_y[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4mvr4lQ561F8",
        "outputId": "cec54c4c-2877-4219-9c0b-b646d717dc53"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 10])\n",
            "Output size :  torch.Size([100, 30])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "func = nn.LogSigmoid()\n",
        "output_x = func(x)\n",
        "output_y = func(y)\n",
        "print('Output size : ', output_x.size())\n",
        "print('Output size : ', output_y.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "0wI2XtXC61F9",
        "outputId": "312202f9-fe71-4b56-9c3e-30e70eda32f8"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([-0.9983, -0.2337,  0.7794,  1.0399, -1.4705, -1.4177, -0.2531, -1.0391,\n",
            "        -1.1570, -0.5105])\n",
            "tensor([-1.3120, -0.8168, -0.3775, -0.3027, -1.6773, -1.6346, -0.8277, -1.3420,\n",
            "        -1.4304, -0.9806])\n",
            "tensor([-0.3758, -1.1889,  0.7846,  0.8277,  0.1351,  0.2677, -0.2810, -1.1610,\n",
            "        -0.6973, -0.1106,  0.6361,  1.4497, -0.6007, -0.1102,  0.8876, -0.1440,\n",
            "        -0.2914, -0.0144,  1.4152,  2.1429,  0.8828,  0.9561, -0.1876,  1.1487,\n",
            "         0.6150, -0.1044,  1.3075, -0.1601, -0.4018, -1.2599])\n",
            "tensor([-0.8986, -1.4547, -0.3759, -0.3626, -0.6279, -0.5683, -0.8435, -1.4335,\n",
            "        -1.1014, -0.7500, -0.4249, -0.2108, -1.0379, -0.7498, -0.3448, -0.7677,\n",
            "        -0.8494, -0.7004, -0.2174, -0.1109, -0.3462, -0.3253, -0.7913, -0.2754,\n",
            "        -0.4322, -0.7467, -0.2394, -0.7764, -0.9141, -1.5096])\n"
          ]
        }
      ],
      "source": [
        "print(x[0])\n",
        "print(output_x[0])\n",
        "print(y[0])\n",
        "print(output_y[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "0zapVEqM61F9",
        "outputId": "4eb2b683-12dc-4287-dc86-8c44a0bb3e4e"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 10])\n",
            "Output size :  torch.Size([100, 30])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "func = nn.ReLU()\n",
        "output_x = func(x)\n",
        "output_y = func(y)\n",
        "print('Output size : ', output_x.size())\n",
        "print('Output size : ', output_y.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "KrZfvpH861F-",
        "outputId": "fcf0d7b5-57d6-4d41-fae3-27fc68ae3329"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([-0.6479, -0.8856,  0.5144, -0.5064,  0.3280, -1.8378,  0.5670,  0.9095,\n",
            "        -2.6267, -1.0119])\n",
            "tensor([0.0000, 0.0000, 0.5144, 0.0000, 0.3280, 0.0000, 0.5670, 0.9095, 0.0000,\n",
            "        0.0000])\n",
            "tensor([-1.4458,  0.8328,  0.6534,  2.0404,  0.9053, -0.2829, -0.5712,  0.0323,\n",
            "         0.9757, -1.5787,  1.9665,  1.0276, -1.0536,  0.0588,  0.5085,  0.1956,\n",
            "        -0.4490, -0.8927,  0.0128, -0.5971, -0.0677,  0.0101,  0.9477,  1.1218,\n",
            "        -1.0648, -0.8439,  0.3422,  0.6930, -0.4311, -1.2920])\n",
            "tensor([0.0000, 0.8328, 0.6534, 2.0404, 0.9053, 0.0000, 0.0000, 0.0323, 0.9757,\n",
            "        0.0000, 1.9665, 1.0276, 0.0000, 0.0588, 0.5085, 0.1956, 0.0000, 0.0000,\n",
            "        0.0128, 0.0000, 0.0000, 0.0101, 0.9477, 1.1218, 0.0000, 0.0000, 0.3422,\n",
            "        0.6930, 0.0000, 0.0000])\n"
          ]
        }
      ],
      "source": [
        "print(x[0])\n",
        "print(output_x[0])\n",
        "print(y[0])\n",
        "print(output_y[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "O_IloLJA61F-",
        "outputId": "3cd1b78b-2e71-4009-9d08-2d21124eafcd"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Output size :  torch.Size([100, 10])\n",
            "Output size :  torch.Size([100, 30])\n"
          ]
        }
      ],
      "source": [
        "x = Variable(torch.randn(100, 10))\n",
        "y = Variable(torch.randn(100, 30))\n",
        "\n",
        "func = nn.LeakyReLU()\n",
        "output_x = func(x)\n",
        "output_y = func(y)\n",
        "print('Output size : ', output_x.size())\n",
        "print('Output size : ', output_y.size())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "CIqN-nD961F_",
        "outputId": "dc05be10-0bac-4628-a16c-0adff13311c2"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([ 0.3611, -0.3622,  0.5740, -0.3404, -0.1284,  1.4639,  1.3272,  0.0636,\n",
            "        -1.1366,  1.1084])\n",
            "tensor([ 3.6107e-01, -3.6216e-03,  5.7399e-01, -3.4043e-03, -1.2843e-03,\n",
            "         1.4639e+00,  1.3272e+00,  6.3646e-02, -1.1366e-02,  1.1084e+00])\n",
            "tensor([-0.4000, -0.2603,  0.5494, -1.1904,  1.0810,  0.0770,  0.5700, -1.0860,\n",
            "         0.6954, -0.3596, -0.7211, -0.5289,  1.8362, -1.4268, -1.1033,  0.0696,\n",
            "         0.5678,  0.5952,  0.2172,  0.5269,  1.4032, -0.3520, -0.7009,  0.0710,\n",
            "        -0.2730, -1.4919, -1.3549,  0.1566, -1.0187,  0.0810])\n",
            "tensor([-0.0040, -0.0026,  0.5494, -0.0119,  1.0810,  0.0770,  0.5700, -0.0109,\n",
            "         0.6954, -0.0036, -0.0072, -0.0053,  1.8362, -0.0143, -0.0110,  0.0696,\n",
            "         0.5678,  0.5952,  0.2172,  0.5269,  1.4032, -0.0035, -0.0070,  0.0710,\n",
            "        -0.0027, -0.0149, -0.0135,  0.1566, -0.0102,  0.0810])\n"
          ]
        }
      ],
      "source": [
        "print(x[0])\n",
        "print(output_x[0])\n",
        "print(y[0])\n",
        "print(output_y[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "collapsed": true,
        "id": "LKuRr3kH61GA"
      },
      "outputs": [],
      "source": [
        "import torch.nn.functional as F\n",
        "from torch.autograd import Variable\n",
        "import matplotlib.pyplot as plt\n",
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "id": "A460kQ_u61GA"
      },
      "outputs": [],
      "source": [
        "x = torch.linspace(-10, 10, 1500)  \n",
        "x = Variable(x)\n",
        "x_1 = x.data.numpy()   # tranforming into numpy"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "collapsed": true,
        "id": "i8gF1z8O61GB"
      },
      "outputs": [],
      "source": [
        "y_relu = F.relu(x).data.numpy()\n",
        "y_sigmoid = torch.sigmoid(x).data.numpy()\n",
        "y_tanh = torch.tanh(x).data.numpy()\n",
        "y_softplus = F.softplus(x).data.numpy()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        },
        "id": "A5BENnoi61GB",
        "outputId": "5e1092ab-0fb3-46ee-ba1f-1afd725eeaa2"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.legend.Legend at 0x7fc2bfdf2810>"
            ]
          },
          "metadata": {},
          "execution_count": 19
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 504x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAAD4CAYAAAC5S3KDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1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wTeDso92dcJrMBI2I/g/cpdWVwoMyH4QvniFL3RWod48tzHbAr9rf4Kvy50bnAKmAOUD+2bD4wqtTXXhnbnlcDA+PJoaGOREQkktLtEJ+IiGQJFZSIiESSCkpERCJJBSUiIpGkghIRkUhSQYmISCSpoEREJJL+H//UzeaLWVhHAAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "source": [
        "plt.figure(figsize=(7, 4))\n",
        "plt.plot(x_1, y_relu, c='blue', label='ReLU')\n",
        "plt.ylim((-1, 11))\n",
        "plt.legend(loc='best')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 287
        },
        "id": "Y6m9Rbnc61GB",
        "outputId": "5f16dcf3-b8ee-4be2-ce79-3228bf3c6f37"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.legend.Legend at 0x7fc2bfc87b50>"
            ]
          },
          "metadata": {},
          "execution_count": 20
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 504x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbQAAAD8CAYAAAAfSFHzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXhV1dn38e8NBFDm0QFEUEFlEIeItvIIigNiC9I6VquIihOtOCDY2tbhcaBq69uKKOJQhzJUntKoOFcEZwKiCIpGRQmiAiLFKkLgfv9YJ3IIJyGQnbPP8Ptc176yh5Wz7uyc5D5r7bXXNndHREQk29WJOwAREZEoKKGJiEhOUEITEZGcoIQmIiI5QQlNRERyghKaiIjkhEgSmpndZ2Zfmtk7lRw/3czeNrP5ZvaKmfWMol4REZFyUbXQHgD6V3H8Y6CPu/cArgfGR1SviIgIAPWieBF3n2lmHas4/krS5mtA+yjqFRERKRdJQttG5wBPpjpgZsOAYQCNGjU6aJ999klnXCIikuHmzJmzwt3bpDqW1oRmZkcQElrvVMfdfTyJ7sjCwkIvLi5OY3QiIpLpzOyTyo6lLaGZ2X7ABOA4d1+ZrnpFRCQ/pGXYvpl1AP4P+KW7v5+OOkVEJL9E0kIzs4lAX6C1mZUCfwAKANz9LuD3QCvgTjMDKHP3wijqFhERgehGOZ62lePnAudGUZeISDZbv349paWlrF27Nu5QMlrDhg1p3749BQUF1f6eOEY5iojkrdLSUpo0aULHjh1J9FhJBe7OypUrKS0tpVOnTtX+Pk19JSKSRmvXrqVVq1ZKZlUwM1q1arXNrVglNBGRNFMy27rtOUdKaCIikhOU0ERE8ty5557LwoULa7WOAQMG8PXXX2+x/5prruHWW2+NpA4NChERyXMTJkyo9TqmT59e63WohSYikkf++9//cvzxx9OzZ0+6d+/O5MmT6du3L+VTDd5777106dKFXr16cd555zF8+HAAhgwZwoUXXsihhx7KHnvswYwZMxg6dCj77rsvQ4YM+eH1J06cSI8ePejevTujRo36YX/Hjh1ZsWIFADfccANdunShd+/eLFq0KLKfTS00EZGYjBgB8+ZF+5r77w+331758aeeeopdd92VJ554AoDVq1czbtw4AD777DOuv/565s6dS5MmTTjyyCPp2XPT4ytXrVrFq6++SlFREQMHDuTll19mwoQJHHzwwcybN4+2bdsyatQo5syZQ4sWLTjmmGOYNm0aJ5xwwg+vMWfOHCZNmsS8efMoKyvjwAMP5KCDDorkZ1cLTUQkj/To0YNnn32WUaNGMWvWLJo1a/bDsTfeeIM+ffrQsmVLCgoKOOmkkzb73p/+9KeYGT169GCnnXaiR48e1KlTh27durF48WJmz55N3759adOmDfXq1eP0009n5syZm73GrFmzGDx4MDvuuCNNmzZl4MCBkf1saqGJiMSkqpZUbenSpQtz585l+vTpXH311fTr16/a39ugQQMA6tSp88N6+XZZWdk2zepRG9RCExHJI5999hk77rgj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omwhMCHpe4cm3s8lwNk1jUVTX4mISE7I9S5HERHJE0poIiKSE5TQREQkJyihiYhITlBCExGRnKCEJiIiOUEJTUREcsL/B+XtYFanXrNhAAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "source": [
        "plt.figure(figsize=(7, 4))\n",
        "plt.plot(x_1, y_sigmoid, c='blue', label='sigmoid')\n",
        "plt.ylim((-0.2, 1.2))\n",
        "plt.legend(loc='best')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        },
        "id": "dm1BlKru61GC",
        "outputId": "df69a1fa-5387-41da-f657-b898925b84f2"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.legend.Legend at 0x7fc2bf7c5150>"
            ]
          },
          "metadata": {},
          "execution_count": 21
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 504x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbQAAAD4CAYAAACE2RPlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAbTklEQVR4nO3de5wV9X3/8deHZQGNqFwVQbJoUPGSIK7EC6YoKpdGVFINaU20tvKI0faXWxMaHw9jkj4e1fhI0jTVKF6qtd4ao3UlFAWCVSvKHhBkEZSFYFxErhFRQFj28/tjZvG4nmV3OZfvmTnv5+NxHmcu3z3z2dnZfe/MfGfG3B0REZGk6xa6ABERkUJQoImISCoo0EREJBUUaCIikgoKNBERSYXuoQtoT//+/b2mpiZ0GSIiUkYWLVq02d0H5JpXtoFWU1NDJpMJXYaIiJQRM3uzvXk65CgiIqmgQBMRkVRQoImISCqU7Tm0XPbs2UNT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tAj4ENgBPZ827gaj32OvAxKzps4Cj4uFjiIKuEfgN0DPA93Af8PU2044CZmXVuDR+LSc6lBZqfT8ALANejTfcQW3rjccnEfV8Wx243kaiY/VL4ldrT8GyWr+51hfwY6IgBugVb5+N8fZ6TKh1Gtczhuiw86tZ63YS8PXWbRm4Pl6fS4k65JwVsN6cP+M29RpwW/wzWEZWr+mAdX+KKKAOy5pWNuuYKGjXA3viv8N/Q3Rudx6wCpgL9I3b1gJ3Z33t1fH23Aj8db616NZXIiKSCmk/5CgiIhVCgSYiIqmgQBMRkVRQoImISCoo0EREJBUUaCIikgoKNBERSYX/D4yQGwcp2LC4AAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "source": [
        "plt.figure(figsize=(7, 4))\n",
        "plt.plot(x_1, y_tanh, c='blue', label='tanh')\n",
        "plt.ylim((-1.2, 1.2))\n",
        "plt.legend(loc='best')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 22,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        },
        "id": "eTRgAPER61GD",
        "outputId": "65cca173-5e2e-41be-aa69-134d561b3b60"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.legend.Legend at 0x7fc2bf73e8d0>"
            ]
          },
          "metadata": {},
          "execution_count": 22
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 504x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAAD4CAYAAAC5S3KDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAf70lEQVR4nO3de5yWc/7H8deng05SqZaiVH5Cqi07WGLJKR2UCisS4tcPG7W7ktjsPJyPqyw6bvippbZCOo9SyiNRSSFW6Og05Vc6bMf5/v743jGNmZru0/c+vJ+Pxzzmnvu+Zq73XHPPvOe67u/1vcw5h4iISKopEzqAiIhIcVRQIiKSklRQIiKSklRQIiKSklRQIiKSksolc2W1atVyDRo0SOYqRUQkhS1evHiDc652cY8ltaAaNGjAokWLkrlKERFJYWa2uqTHdIhPRERSkgpKRERSkgpKRERSUlJfgyrO7t27WbduHTt27AgdJaVVrFiRY489lvLly4eOIiKSFMELat26dVStWpUGDRpgZqHjpCTnHBs3bmTdunU0bNgwdBwRkaQIfohvx44d1KxZU+V0AGZGzZo1tZcpIlkleEEBKqdS0DYSkWyTEgUlIiJSlArqEMybN49TTjmFFi1asGDBAqZOnXrQz1m1ahVNmzZNQjoRkcyigjoEY8aMYcCAASxdupTPPvusVAUlIiLRyfqC2rZtG+3bt+fXv/41TZs2ZezYscyaNYuWLVvSrFkzevbsyc6dOxk5ciTjxo1j4MCBdOvWjXvvvZexY8fSokULxo4dS25uLtdeey1nnnkmJ5xwAiNGjPjFul544QV69+7908cdOnRgzpw57N27l+uvv56mTZvSrFkznnrqqWRuAhGRlBR8mHlhffvC0qXx/ZotWsCgQSU/Pn36dOrWrcuUKVMA2Lx5M02bNmXWrFk0btyYHj16MGTIEPr27cv8+fPp0KEDl19+OS+88AKLFi3imWeeASA3N5dly5bx7rvvsm3bNlq2bEn79u1LlXHp0qWsX7+ejz76CIBNmzbF9k2LiGSArN+DatasGXl5efTv35958+axatUqGjZsSOPGjQG47rrrePvtt0v1tTp16kSlSpWoVasWrVu35r333ivV5zVq1Igvv/yS2267jenTp3PEEUdE/f2IiGSKlNqDOtCeTqI0btyYJUuWMHXqVP7yl79w/vnnR/21ig4FL/pxuXLlKCgo+Onjfec11ahRgw8//JAZM2YwdOhQxo0bx6hRo6LOISKSCbJ+D+rrr7+mcuXKdO/enX79+rFgwQJWrVrFypUrAXjppZc499xzf/F5VatWZcuWLfvd9/rrr7Njxw42btzInDlzOO200/Z7vEGDBixdupSCggLWrl370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GIeusc593qy8xyqUubvxoH3ns52zq03s18BeWb2aeQ/l7g7UF5gCHA//hf9fvxhyZ6JyHEoSrONzeweYA8wpoQvk7RtnCnM7HBgAtDXOfdjkYeX4A9JbY28VvkacEKyMxaRdj/jyOviHYEBxTycitt4P845Z2YJP0cpWEE55y6M4tNKc4mPjfhd+HKR/0gTchmQg+U3s3JAF+A3B/ga6yPvvzezV/GHhBLyi1Xa7W1mI4DJxTyU9MurlGIbXw90AC5wkQPgxXyNpG3jYpRmm+1bZl3kOVMN/xwOwszK48tpjHNuYtHHCxeWc26qmT1nZrWcc8EmOS3FzzgVLw3UFljinPuu6AOpuI0jvjOzOs65byKHSL8vZpn1+NfQ9jkWP5YgKul2iG8ScFVk5FND/H8V7xVeIPKH6i3g8shd1wEh9sguBD51zq0r7kEzq2JmVffdxr/o/1FxyyZakePxnUvIkVKXVzGzS4A7gY7Oue0lLBN6G5dmm03CP0fBP2dnl1S2iRZ57esfwArn3N9KWObofa+Rmdnp+L8hIQu1ND/jSUCPyGi+3wKbCx2qCqXEoyupto0LKfxcLenv6gzgYjOrEXmp4OLIfdEJOVKkpDf8H8l1wE7gO2BGocfuwY+M+gxoW+j+qUDdyO1G+OJaCfwLqBDge3gBuLnIfXWBqYUyfhh5+xh/2CrU9n4JWA4sizwJ6xTNG/m4HX5k1xch80ayrMQf614aeds3Ei6ltnFx2wy4D1+sABUjz9GVkedso4Db9Gz8Yd5lhbZrO+Dmfc9loHdkW36IH5xyVuDnQbE/4yKZDXg28jNYTqGRwYEyV8EXTrVC96XUNsaX5zfA7sjf4hvxr43OAj4H3gSOjCybA4ws9Lk9I8/nlcANseTQVEciIpKS0u0Qn4iIZAkVlIiIpCQVlIiIpCQVlIiIpCQVlIiIpCQVlIiIpCQVlIiIpKT/B6UAYpYmuXq+AAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "source": [
        "plt.figure(figsize=(7, 4))\n",
        "plt.plot(x_1, y_softplus, c='blue', label='softplus')\n",
        "plt.ylim((-0.2, 11))\n",
        "plt.legend(loc='best')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 23,
      "metadata": {
        "collapsed": true,
        "id": "aP1odC6d61GD"
      },
      "outputs": [],
      "source": [
        "def prep_data():\n",
        "    train_X = np.asarray([13.3,14.4,15.5,16.71,16.93,14.168,19.779,16.182,\n",
        "                          17.59,12.167,17.042,10.791,15.313,17.997,15.654,\n",
        "                          19.27,13.1])\n",
        "    train_Y = np.asarray([11.7,12.76,12.09,13.19,11.694,11.573,13.366,12.596,\n",
        "                          12.53,11.221,12.827,13.465,11.65,12.904,12.42,12.94,\n",
        "                          11.3])\n",
        "    dtype = torch.FloatTensor\n",
        "    X = Variable(torch.from_numpy(train_X).type(dtype),\n",
        "                 requires_grad=False).view(17,1)\n",
        "    y = Variable(torch.from_numpy(train_Y).type(dtype),requires_grad=False)\n",
        "    return X,y"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 24,
      "metadata": {
        "collapsed": true,
        "id": "DVryHmSW61GD"
      },
      "outputs": [],
      "source": [
        "# get dynamic parameters"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "collapsed": true,
        "id": "mkoMb2bB61GD"
      },
      "outputs": [],
      "source": [
        "def set_weights():\n",
        "    w = Variable(torch.randn(1),requires_grad = True)\n",
        "    b = Variable(torch.randn(1),requires_grad=True)\n",
        "    return w,b"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 26,
      "metadata": {
        "collapsed": true,
        "id": "UGuKavsI61GE"
      },
      "outputs": [],
      "source": [
        "#deploy neural network model"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 27,
      "metadata": {
        "collapsed": true,
        "id": "wxNs7d4f61GE"
      },
      "outputs": [],
      "source": [
        "def build_network(x):\n",
        "    y_pred = torch.matmul(x,w)+b\n",
        "    return y_pred"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 28,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "PHBqbn9D61GE",
        "outputId": "49da70e2-d18d-4c78-becf-1e6a8d311686"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Linear(in_features=17, out_features=1, bias=True)"
            ]
          },
          "metadata": {},
          "execution_count": 28
        }
      ],
      "source": [
        "#implement in PyTorch\n",
        "import torch.nn as nn\n",
        "f = nn.Linear(17,1) # Much simpler.\n",
        "f"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "collapsed": true,
        "id": "wxh4e4b-61GF"
      },
      "outputs": [],
      "source": [
        "#calculate the loss function"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 35,
      "metadata": {
        "collapsed": true,
        "id": "Nh4jA4H561GF"
      },
      "outputs": [],
      "source": [
        "def loss_calc(y,y_pred):\n",
        "    loss = (y_pred-y).pow(2).sum()\n",
        "    for param in [w,b]:\n",
        "        if not param.grad is None: param.grad.data.zero_()\n",
        "    loss.backward()\n",
        "    return loss.data"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 36,
      "metadata": {
        "collapsed": true,
        "id": "JrM-2sCf61GF"
      },
      "outputs": [],
      "source": [
        "# optimizing results"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 37,
      "metadata": {
        "collapsed": true,
        "id": "lMRYtQ_261GF"
      },
      "outputs": [],
      "source": [
        "def optimize(learning_rate):\n",
        "    w.data -= learning_rate * w.grad.data\n",
        "    b.data -= learning_rate * b.grad.data"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 38,
      "metadata": {
        "collapsed": true,
        "id": "FUXYASCD61GG"
      },
      "outputs": [],
      "source": [
        "learning_rate = 1e-4"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 39,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "N6o2Vuhy61GG",
        "outputId": "67e21a5b-9845-4d52-c70e-709460962e22"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor(5954.0488)\n",
            "tensor(44.9320)\n",
            "tensor(39.5382)\n",
            "tensor(34.9094)\n",
            "tensor(30.9371)\n"
          ]
        }
      ],
      "source": [
        "x,y = prep_data()  # x - training data,y - target variables\n",
        "w,b = set_weights() # w,b - parameters\n",
        "for i in range(5000):\n",
        "    y_pred = build_network(x) # function which computes wx + b\n",
        "    loss = loss_calc(y,y_pred) # error calculation\n",
        "    if i % 1000 == 0: \n",
        "        print(loss)\n",
        "    optimize(learning_rate)    # minimize the loss w.r.t. w, b"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 40,
      "metadata": {
        "collapsed": true,
        "id": "sTb-AV9I61GG"
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 41,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        },
        "id": "_wK7dOLB61GG",
        "outputId": "e5430fcf-6f9e-437f-bcf7-cb8ae7ae4024"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[<matplotlib.lines.Line2D at 0x7fc2bf6045d0>]"
            ]
          },
          "metadata": {},
          "execution_count": 41
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAZQ0lEQVR4nO3deXxU1d3H8c8PpBC1JSKgoMRYRSxuoLG1ahWXCo8bSK2tu5WnPFrrVkXBBeJWqbhUrbZFQcRaXlpBsNAWFxTUurGooKgoAhJEVAQ3kCXn+WOCkzuZYZLJ3Dn3znzf/8A5M8n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r6dmT1hZgvq/tymMd9PAZ67MUCflLkngD2dc3sD7wBDCl2UR2No+H5gZl2Ao4AlhS7IozGkvBdmdhjQF9jHObcHcLOHunwZQ8PfjZuAa5xzPYChdeNSsAG4xDnXHTgAOM/MugODgaecc12Bp+rGWSnAc+ScmwGsTJl73Dm3oW74IlAyN/BM937UuQ24DCiZo+UZ3otzgeHOuW/qnrOi4IV5kuH9cMD36v7eFlhW0KI8cc596JybXff3L4D5wA4k/nO/v+5p9wP9GvP9FODhORv4t+8ifDKzvkCNc+4137VEwG7AT8zsJTObbmb7+y7Is4uAEWb2AYlPI6X0aRUAM6sEegIvAds55z6se2g5sF1jvocCPARmdiWJj0oP+q7FFzPbEriCxMdjSdxAvB2Jj82DgIfNzPyW5NW5wMXOuS7AxcAoz/UUlJltDYwHLnLOfV7/MZc4t7tRn1gV4HlmZmcBxwKnutI+yX4XYGfgNTNbRGI5abaZbe+1Kn+WAhNcwstALYkNjErVmcCEur//AyiJg5gAZtaKRHg/6Jzb9B58ZGad6h7vBDRqiU0Bnkdm1ofEeu/xzrmvfdfjk3NurnOuo3Ou0jlXSSLA9nXOLfdcmi8TgcMAzGw34DuU9m58y4BD6/5+OLDAYy0FU/epaxQw3zl3a72HHiPxnxp1f05q1Pcr7SYxd2Y2DuhFoov6CBhGYh2vNfBp3dNedM6d46XAAkv3fjjnRtV7fBFQ5Zwr+tDK8LvxADAa6AGsAy51zk3zVWMhZXg/3gZuJ7G0tBb4jXNulq8aC8XMDgaeBeaS+BQGiaXGl4CHgQoSW26f5JxLd1JA8PspwEVE4klLKCIiMaUAFxGJKQW4iEhMKcBFRGJKAS4iElMKcBGRmFKAi4jE1P8DJKmZuwUdJOkAAAAASUVORK5CYII=\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "source": [
        "x_numpy = x.data.numpy()\n",
        "y_numpy = y.data.numpy()\n",
        "y_pred = y_pred.data.numpy()\n",
        "plt.plot(x_numpy,y_numpy,'o')\n",
        "plt.plot(x_numpy,y_pred,'-')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 42,
      "metadata": {
        "collapsed": true,
        "id": "65OROyBG61GG"
      },
      "outputs": [],
      "source": [
        "x = Variable(torch.ones(4, 4) * 12.5, requires_grad=True)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 43,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "I5DKAY7w61GH",
        "outputId": "91f4dfe3-5859-4887-94f5-5c4508f64114"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "tensor([[12.5000, 12.5000, 12.5000, 12.5000],\n",
              "        [12.5000, 12.5000, 12.5000, 12.5000],\n",
              "        [12.5000, 12.5000, 12.5000, 12.5000],\n",
              "        [12.5000, 12.5000, 12.5000, 12.5000]], requires_grad=True)"
            ]
          },
          "metadata": {},
          "execution_count": 43
        }
      ],
      "source": [
        "x"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 44,
      "metadata": {
        "collapsed": true,
        "id": "06ZRd18A61GH"
      },
      "outputs": [],
      "source": [
        "fn = 2 * (x * x) + 5 * x + 6\n",
        "\n",
        "# 2x^2 + 5x + 6"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 45,
      "metadata": {
        "id": "8R_j4jfs61GI"
      },
      "outputs": [],
      "source": [
        "fn.backward(torch.ones(4,4))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 46,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "XXyZ_ZP761GI",
        "outputId": "8e278dba-0c88-428c-fbf6-9174cfd721a0"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "tensor([[55., 55., 55., 55.],\n",
            "        [55., 55., 55., 55.],\n",
            "        [55., 55., 55., 55.],\n",
            "        [55., 55., 55., 55.]])\n"
          ]
        }
      ],
      "source": [
        "print(x.grad)"
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "bd6fd4ly9coh"
      },
      "execution_count": null,
      "outputs": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.4"
    },
    "colab": {
      "name": "Torch_AI_4_2Ed.ipynb",
      "provenance": [],
      "collapsed_sections": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}